package Server.ServerCore.Repository;

import Server.ExtComponents.MyBatis.OrmProviderFactory;
import Server.ServerCore.Model.Player.PlayerInstance;
import Server.ServerCore.Model.dbsql.mapper.GameRoleMapper;
import Server.ServerCore.Model.dbsql.model.GameRole;
import Server.ServerCore.Model.dbsql.model.GameRoleExample;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * @author :石头哥哥<br/>
 *         Project:21Server
 *         Date: 13-4-4
 *         Time: 下午9:54
 */
@Repository
public class ChipsServiceImpl implements ChipsService {

    @Resource
    private OrmProviderFactory providerFactory;


    @Override
    public void updateChips(GameRole gameRole, double chips) {
        //获取session
        SqlSession Session = OrmProviderFactory.getOrmProviderFactory().getSimpleSqlSession();
        try {
            GameRoleMapper gameAccountMapper=Session.getMapper(GameRoleMapper.class);
            gameRole.setRoleBargainingChip(chips);
            gameAccountMapper.updateByPrimaryKey(gameRole);
        }finally {
            Session.close();
        }
    }
}
